import { createSlice } from '@reduxjs/toolkit';

import { ReduxState } from '..';

type Custom = {
  btmShow: number;
  originalTimer: number;
  originalSecond: number;
  playOrPause: boolean;

  weather: [];
  systemInfo: any;
}

type customSelect = <T extends keyof Custom>(custom: T) => (state: ReduxState) => Custom[T];

const custom: Custom = {
  btmShow: 1,
  originalTimer: 0,
  originalSecond: 0,
  playOrPause: true,

  weather: [],
  systemInfo: {},
};

const customSlice = createSlice({
  name: 'custom',
  initialState: custom,
  reducers: {
    setBtmShow: (state, action) => {
      state.btmShow = action.payload;
    },
  
   
    setPlayOrPause: (state, action) => {
      state.playOrPause = action.payload;
    },
    setOriginalTimer: (state, action) => {
      state.originalTimer = action.payload;
    },
    setOriginalSecond: (state, action) => {
      state.originalSecond = action.payload;
    },
 
    setWeather: (state, action) => {
      state.weather = action.payload;
    },
    setSystemInfo: (state, action) => {
      state.systemInfo = action.payload;
    },
 
 

  },
  extraReducers: builder => { },
});

export const { setBtmShow, setPlayOrPause, setOriginalTimer, setOriginalSecond,setWeather, setSystemInfo } = customSlice.actions;

export const selectCustom: customSelect = params => state => state.custom[params];

export default customSlice.reducer;
